/*
 * Program demonstrate copy from an input to second array
 */
#include <stdio.h>

// max length of string
int MAXLINE = 1000; 
int agetline(char* a_Array, int lim);
void strcat(char* a_First, char* a_Second);

int main(int argc, const char** argv)
{
    char a[MAXLINE];
    char b[MAXLINE];

    while (agetline(a, MAXLINE) > 0)
    {
        strcat(a, b);
        printf("%s\n", b);
    }
}


void strcat(char* a_First, char* a_Second)
{

    while ((*a_Second) != '\0')
        a_Second++;
    while ((*a_Second = *a_First) != '\0')
    {
        a_Second++;
        a_First++;
    }
}

int agetline(char* a_Array, int lim)
{
    int c, i = 0;

    while (--lim > 0 && (c = getchar()) != 'Q' && c != '\n')
    {
        a_Array[i++] = c;
    }
    a_Array[i] = '\0';
    return i;
}
